/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */


struct ListNode* removeElements(struct ListNode* head, int val){
    typedef struct ListNode ListNode;
    //首先一个题目下来，你首先要考虑的就是非法值
    ListNode* First;
    First=(ListNode *)malloc(sizeof(ListNode));
    First->next=head;
    ListNode * Phead=First;
    while(Phead->next!=NULL){
        if (Phead->next->val==val){
            ListNode * tem=Phead->next;
            Phead->next=Phead->next->next;
            free(tem);
        }
        else {
            Phead=Phead->next;
        }
    }
    head=First->next;
    free(First);
    return head;

}